﻿@{
    Layout = "../Shared/_InnerPage.cshtml";
}
@model XoohooViewModelItem<IEnumerable<Permission>>
@section TitleContent{
    @Html.SiteTitle("系统管理", "用户管理", "权限管理", "权限列表")
}
@section HeadCustom{
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            $(".delete>a").click(function () {
                if (!confirm("警告！删除该权限后，将无法恢复！\n确定要删除该权限？")) {
                    return false;
                } 
            });
        });
    </script>
}
@section NavigationContent
{
    当前位置：用户管理 &gt;&gt; 权限管理 &gt;&gt; 权限列表
}
@{
    IEnumerable<Permission> permissions = Model.Item;
    Html.BeginRouteForm("Admin.Membership.User.PermissionList", FormMethod.Post, new { @id = "PermissionSearchForm", @name = "PermissionSearchForm" });
    if (!permissions.IsNullOrEmpty())
    {
        int maxDisplayOrder = permissions.Max(v => v.DisplayOrder);
        WriteLiteral(Html.Grid(permissions).Columns(column =>
        {
            column.For(item => item.DisplayOrder).Named("顺序").HeaderAttributes(@class => "titNum").Attributes(@class => "conNum");
            column.For(item => item.ModuleName).Named("模块名称").HeaderAttributes(@class => "tit120").Attributes(@class => "con120");
            column.For(item => item.PermissionName).Encode(false).Named("权限名称").HeaderAttributes(@class => "titOth").Attributes(@class => "conOth");
#if DEBUG
    column.For(item => Html.ActionLink("添加子权限", "PermissionAdd", new { ParentID = item.PermissionID })).Encode(false).Attributes(@class => "conCtr2");
    column.For(item => Html.ActionLink("上移", "PermissionMove", new { PermissionID = item.PermissionID,Target=MovingTarget.Up })).Encode(false).Attributes(@class => "conCtr").CellCondition(p => p.DisplayOrder!=1);
    column.For(item => Html.ActionLink("下移", "PermissionMove", new { PermissionID = item.PermissionID,Target=MovingTarget.Down })).Encode(false).Attributes(@class => "conCtr").CellCondition(p=>p.DisplayOrder!=maxDisplayOrder);
    column.For(item => Html.ActionLink("编辑", "PermissionEdit", new { PermissionID = item.PermissionID })).Encode(false).Attributes(@class => "conCtr");
    column.For(item => Html.ActionLink("删除", "PermissionRemove", new { PermissionID = item.PermissionID })).Encode(false).Attributes(@class => "conCtr delete");
#endif
        })
            //表格属性
.Attributes(@class => "tbl")
            //表头行属性
    .HeaderRowAttributes(new Hash(@class => "rowhead"))
            //列表行属性
.RowAttributes(data => new Hash(@class => "{0}".FormatWith(data.IsAlternate ? "rowodd" : ""))));
    }
}
@{Html.EndForm();}
